<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of soaUsers
 *
 * @author dxx
 */

namespace app\common\model\jsm;

use think\Model;

class Mps extends Model {

    protected $table = 'jj_mps';
    protected $connection = ['database' => 'jooj_jsm'];

    public function __construct($data = []) {
        parent::__construct($data);
    }

    
    /**
     * 通过company_id获取mp_id相关信息
     * @param type $company_id
     */
    public function getMpIdByCompanyId($companyId) {
        $res = $this->field('mp_id')->where(['o_id' => "$companyId"])->cache(true,3600)->find()['mp_id'];
        return $res;
    }

    /**
     * 通过条件获取MPSINFO
     * @param type $condition
     * @param type $filed
     * @return type
     */
    public function getMpsInfoByCondition($condition, $field = '*') {
        $ret = $this->where($condition)->field($field)->cache(true,3600)->find();
        return $ret;
    }
    
    /**
     * 通过appid获取Mps相关信息
     * @param type $app_id
     * @param type $is_chache
     */
    public function getMpsByAppId($app_id, $is_cache = false) {
        $res = $this->setTable($this->table)->where(['authorizer_appid' => "$app_id"])->cache($is_cache, 3600)->find();
        return $res;
    }
}
